import time
import unittest
if __name__ == '__main__':
    # 批量加载
    test_dir=r'..\test_case'
    discover=unittest.defaultTestLoader.discover(test_dir,pattern='test*.py')
    # 拼装测试报告文件
    report_dir=r'../reports_assert'
    now=time.strftime('%Y_%m_%d_%H_%M_%S')
    report_name=rf'{report_dir}/{now}unittest.txt'
    #批量执行
    with open(report_name,'w') as f:
        runner=unittest.TextTestRunner(f)
        runner.run(discover)